#include<bits/stdc++.h>
using namespace std;
string s1[10000];
string s2[10000];
int main(){
	int i=0;
	char c;
	while(1){
		c=getchar();
		if(c=='<'){
			if(s1[i].length()>0) s1[i]=s1[i].substr(0,s1[i].length()-1);
		}else if(c!='\n'){
			s1[i]+=c;
		}else{
			if(s1[i].length()==3&&s1[i][0]=='E'&&s1[i][1]=='O'&&s1[i][2]=='F') break;
			i++;
		}
	}

	int j=0;
	int k=0;
	while(1){
		c=getchar();
		if(c=='<'){
			if(s2[j].length()>0) s2[j]=s2[j].substr(0,s2[j].length()-1);
		}else if(c!='\n'){
			s2[j]+=c;
		}else{
			if(s2[j].length()==3&&s2[j][0]=='E'&&s2[j][1]=='O'&&s2[j][2]=='F') break;
			j++;
		}
	}

	int t;
	cin>>t;
	int ii=0,jj=0;
	int cnt=0;
	while(ii<i&&jj<j){
		int iii=0,jjj=0;
		while(iii<s1[ii].length()&&jjj<s2[jj].length()){
			if(s1[ii][iii]==s2[jj][jjj]) cnt++;
			iii++;
			jjj++;
		}
		ii++;
		jj++;
	}
	cout<<round(cnt*60.0/t);
	return 0;
}